-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add optional argument to ReadNext that allows precise seeking #11
Conversation
allow LeaveContainer to be called without reading to the end
Bonus question: How do you feel about updating to .NET 5? This would require removing support for .Net Framework. |
@cvium thanks for bringing that. I don't like an idea of making optional parameter for various reasons such as poor binary compatibility, poor class contract. The purpose of the method is not exactly followed and redundant actions are made. My suggestion is to make another method and call it ReadAt(long position). Let's discuss that approach. re upgrading: what's the purpose? |
I did that initially but ended up basically copying ReadNext. I've made it a bit cleaner now I think.
You are correct, but Netstandard is outdated and from .NET 5 there is no longer netstandard and netcore. There's only netX.0 moving forward. The benefit for NEbml is the addition of Span and Memory structs, which are significantly faster and has a smaller memory footprint (stack allocations instead of heap). |
That looks good! However why did you change ReadNext implementation? |
I have moved ReadAt below ReadNext.
I didn't change it per se. I extracted the Element-parsing to its own private method because ReadNext and ReadAt both require it. |
Nice, thank you! |
bonus: allow LeaveContainer to be called without reading to the end
Reason for changes
I am trying to write a fast parser for the Matroska container, which Ebml was originally made for. Your lib seems to be the best way to achieve this without big rewrites.
I have added an optional argument to ReadNext which allows reading the next element at a specific position. In conjunction with
SeekHead
this enables you to seek to a desired segment without seeking through the whole file.As a bonus I made some changes to LeaveContainer such that it handles leaving a container without reading all elements. I didn't see a reason not to allow it, but maybe you have/had a valid reason?